package com.jn.principle.inversion.improve;

/**
 * 依赖倒置原则
 *
 * @author 江南大学1033190417
 * @date 2022/4/9 22:58
 */
public class DependecyInversion {
    public static void main(String[] args) {
        new Person().receive(new WEIXIN());
    }
}

//定义一个接口
interface IReceiver {
    String getInfo();
}

class Email implements IReceiver {
    public String getInfo() {
        return "电子邮件";
    }
}

class WEIXIN implements IReceiver {
    @Override
    public String getInfo() {
        return "微信";
    }
}


class Person {
    public void receive(IReceiver receiver) {
        System.out.println(receiver.getInfo());
    }
}
